package cn.edu.qfnu.common.utils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;

/**
 * OnlineJudge of QF_NU
 * Created by LS on 2017/7/17.
 */
public final class GenericsUtils {

    public static Class getSuperClassGenricType(Class c) {

        Class aClass = c.getClass();
        Type t = aClass.getGenericSuperclass();
        if (t instanceof ParameterizedType) {
            System.out.println("in if");
            Type[] p = ((ParameterizedType) t).getActualTypeArguments();
            System.out.println(Arrays.toString(p));
            return (Class) p[0];
        }
        return Object.class;
    }
}
